home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_015 / fish / atest.c next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  159 lines

  1. #include "fishes.h"
  2. #include <stdio.h>
  3.  
  4. #define WIDTH   320
  5. #define HEIGHT  200 
  6. #define DEPTH 3 
  7.  
  8. short bpdata[] =
  9.    {
  10.    0x000, 0x5ef, 0x128, 0xd81, 0x326, 0x203, 0x086, 0x044,
  11.    0x5ef, 0x633, 0x855, 0x857, 0x065, 0x669, 0x223, 0x547
  12.    };
  13.  
  14. struct GelsInfo *GInfo;
  15. struct VSprite *head, *tail;
  16. struct collTable *boom;
  17. struct BitMap   bitmap[2];
  18.  
  19. show(screen,view,vp,rp,window)
  20. struct Screen *screen;
  21. struct View *view;
  22. struct ViewPort *vp;
  23. struct RastPort *rp;
  24. struct Window *window;
  25. {
  26.     short dispIndex;
  27.     short i, i2, j,k;
  28.     struct IntuiMessage *message;
  29.     struct AnimOb *animKey;
  30.     struct BitMap *OldI_BitMap;        
  31.  
  32.     OldI_BitMap = rp->BitMap;
  33.  
  34.     if ((boom = (struct collTable *)AllocMem(sizeof
  35.         (struct collTable),MEMF_PUBLIC+MEMF_CLEAR )) == 0)
  36.         {
  37.             exit(1);
  38.         }
  39.  
  40.     if ((head = (struct VSprite *)AllocMem(sizeof(struct VSprite),
  41.         MEMF_PUBLIC+MEMF_CLEAR )) == 0)
  42.         {
  43.             exit(1);
  44.         }
  45.  
  46.     if ((tail = (struct VSprite *)AllocMem(sizeof(struct VSprite),
  47.         MEMF_PUBLIC+MEMF_CLEAR )) == 0)
  48.         {
  49.             exit(1);
  50.         }
  51.  
  52.     if ((GInfo = (struct GelsInfo *)AllocMem(sizeof(struct GelsInfo),
  53.         MEMF_PUBLIC+MEMF_CLEAR )) == 0)
  54.         {
  55.             exit(1);
  56.         }
  57.  
  58.     GInfo->nextLine = 0;
  59.     GInfo->lastColor = 0;
  60.     GInfo->leftmost = 0;
  61.     GInfo->topmost = 0;
  62.     GInfo->rightmost = WIDTH -1;
  63.     GInfo->bottommost = HEIGHT - 1;
  64.     GInfo->collHandler = boom;
  65.     GInfo->sprRsrvd = -1;
  66.     rp->GelsInfo = GInfo;
  67.     InitGels(head,tail,GInfo);
  68.     
  69.  
  70.     LoadRGB4(vp,bpdata,16);
  71.     SetRast(rp,0);
  72.  
  73.     for(i=0; i<2; i++)
  74.     {    
  75.         InitBitMap(&bitmap[i],DEPTH,WIDTH,HEIGHT);
  76.         for(j=0; j<DEPTH; j++)
  77.         {    
  78.            if ((bitmap[i].Planes[j] = (PLANEPTR)AllocRaster(WIDTH,HEIGHT)) == 0)
  79.            {
  80.               exit(2);
  81.            }
  82.            else
  83.            {
  84.                BltClear(bitmap[i].Planes[j],RASSIZE(WIDTH,HEIGHT),0);
  85.            }
  86.         }
  87.     };
  88.  
  89.     rp->Flags = DBUFFER;
  90.     rp->Mask = -1;        
  91.  
  92.     vp->RasInfo->BitMap = &bitmap[1];
  93.     rp->BitMap = &bitmap[1];
  94.     SetRast(rp,0);
  95.  
  96.     vp->RasInfo->BitMap = &bitmap[0];
  97.     rp->BitMap = &bitmap[0];
  98.     SetRast(rp,0);
  99.  
  100.     animinit(&animKey,vp,rp);
  101.  
  102.     dispIndex = 0;
  103.  
  104. restart:
  105.     while((message = (struct IntuiMessage *)GetMsg(window->UserPort)) == NULL)
  106.         {
  107.         Animate(&animKey, rp);
  108.         SortGList(rp);
  109.         WaitTOF();
  110.         DrawGList(rp,vp); 
  111.         vp->RasInfo->BitMap = &bitmap[dispIndex]; 
  112.         WaitTOF();
  113.            MakeScreen(screen);    
  114.         WaitBlit();
  115.         RethinkDisplay();
  116.         dispIndex ^= 1;
  117.         rp->BitMap = &bitmap[dispIndex];
  118.  
  119.         }
  120.     switch(message->Class)
  121.         {
  122.         case CLOSEWINDOW:ReplyMsg(message);
  123.                       free_anim_obj(rp);        
  124.                       for (i = 0; i < 2; i++){
  125.                           for (j = 0; j < DEPTH; j++)
  126.                             {
  127.                             FreeMem(bitmap[i].Planes[j],RASSIZE(WIDTH,HEIGHT)); 
  128.                             };
  129.                         };    
  130.                         FreeMem(boom,sizeof(struct collTable));
  131.                         FreeMem(head,sizeof(struct VSprite));
  132.                         FreeMem(tail,sizeof(struct VSprite));
  133.                         FreeMem(GInfo,sizeof(struct GelsInfo));
  134.                         vp->RasInfo->BitMap = OldI_BitMap;
  135.                         rp->BitMap = OldI_BitMap; 
  136.                         return;
  137.        } 
  138.    ReplyMsg(message);
  139.    goto restart;
  140.               
  141.  
  142. }
  143.  
  144. main()
  145. {
  146.   startgfx(400,80,50,100,2,0,show,"CATHY'S FISH",SMART_REFRESH);
  147.  
  148. }
  149.  
  150. delay()
  151. {
  152.     int i;
  153.     int x;
  154.     for(i = 0; i<10000; i++)
  155.     {
  156.         x += i;
  157.     }
  158. }
  159.